<?php
session_start();
require('../../include/dis.php');
require('employeRH_display.php');
require_once('../employe/employe_display.php');
require_once('../../include/global_display.php');
error_reporting(E_ALL ^ E_NOTICE);


$display['head'] = display_head('Interface du service RH');
$display['header']=display_header('Interface du service RH');
$display['end'] = display_end();
$display['menu'] = dis_menu_employeRH();
$display['menuLeft'] = dis_left_menu();

echo $display['head'];
echo $display['header'];
echo $display['menu'];
echo $display['menuLeft'];
//echo $_SESSION['passe'];

if(isset($_GET['action'])){
	$action=$_GET['action'];

	if($action=="consult"){
		$display['body']=recherche_employeRH();
		$display['res']=resultat_employeRH();		
	}
	
	if($action=="employe"){
	$id =$_GET['id'];
	$display['body']=dis_employe($id);
	}
	
	/* if($action=="saisie" and $_SESSION['passe']=="true"){
		echo 'miou';
	}
	
	if($action=="saisie" and $_SESSION['passe']!="true"){
		$_SESSION['passe']="true";
		$display['body']=saisie_employe();
	}
	*/
	 if($action=="saisie"){
		$display['body']=saisie_employe();		
	}

	
	if($action=="modif") {
	$id =$_GET['id'];
	$display['body']=modif_employe($id);
	$display['body1']=confirm_modif($id);
	
	}
	
		if($action=="saisie_comp" /*and $_SESSION['passe']=="true"*/){
		$display['body']=saisie_competence();
	}
	
	/*if($action=="saisie_comp" and $_SESSION['passe']!="true"){
		echo 'tu reve';
	*/	
	if($action=="afficher"){
		$idComp = $_GET['idcomp'];
		$idEmp = $_GET['idEmpl'];
		$comp=tab_competence($_GET);
		query_insertComp($comp, $idEmp);
		$dest="employeRH_index.php?action=employe&id=$idEmp";
		$_SESSION['passe']="false";
		header("Location:$dest");
	}
	
	if (isset($action) && $action=="conges"){
	$display['body']=dis_employe_conges($_SESSION['id'],$_SESSION['stat']);
	$display['res']=dis_conges($_SESSION['id']);
}

	if (isset($action) && $action=="search"){
	insert_demande_conges($_SESSION['id']);
	header('Location: employeRH_index.php?action=conges');

}

	if (isset($action) && $action=="valid"){
	$display['body']= valid_conges($_SESSION['id'],$_SESSION['stat']);
}

	if (isset($action) && $action=="valid_conges"){
	$tab=true_false($_GET);
	run_query_valid_conges($tab,$_SESSION['stat']);
	$display['body']= valid_conges($_SESSION['id'],$_SESSION['stat']);
}

	if(isset($action) && $action=="nvElt"){
	$display['body']=choix_nvElt();
	$display['res']=saisie_nvElt();
	$display['res1']=enreg_nvElt();
	}
	
if (isset($action) && $action=="afficher_conges"){
	$display['body1']= afficher_conges($_SESSION['id'],$_SESSION['stat']);
	$display['body']= recherche_conges($_SESSION['stat']);
}
	
}

echo $display['body'];
echo $display['body1'];
echo $display['res'];
echo $display['res1'];
echo $display['end'];
?>

